
package robe;

import java.sql.Connection;
import java.sql.DriverManager;


public class Persistencia_Conexion {
    private static Connection con;
    
    public static Connection getConnection(){
        //Si la conexion no estaba creada la crea, sino simplemente la devuelve
        String ruta ="jdbc:mysql://localhost/biciway";
        String user = "root";
        String password = "1234";

            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con=DriverManager.getConnection(ruta,user,password);
            }catch(ClassNotFoundException cnf){
                System.out.println(cnf.getMessage());
            }catch(InstantiationException ie){
                System.out.println(ie.getMessage());
            }catch(IllegalAccessException iae){
                System.out.println(iae.getMessage());
            }catch(Exception e){
                System.out.println(e.getMessage());
            }
        
        return con;
    } 
}
